const express = require('express');

const mysql = require('mysql');

var db = mysql.createPool({
    host: 'localhost',
    user: 'root',
    password: 'mysql123456',
    database: '180618'
});

module.exports=function(){
    var router=express.Router();

    // router.get('/',(req, res)=>{
    //     res.send('我是web').end();
    // });

    router.get('/get_banners',(req, res)=>{
        db.query(`select * from banner_table`,(err, data)=>{
            if(err){
                res.status(500).send('database error').end();
            }else{
                res.send(data).end();
            }
        });
    });

    return router;
};